package com.platform.qujia.controller;


import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.platform.qujia.pojo.GzhFunctionConfig;
import com.platform.qujia.service.GzhFunctionConfigService;
import com.platform.qujia.utils.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (GzhFunctionConfig)表控制层
 *
 * @author makejava
 * @since 2023-12-05 15:03:50
 */
@Api(tags = "公众号小程序页面配置")
@RestController
@RequestMapping("/gzhFunctionConfig")
public class GzhFunctionConfigController {
    /**
     * 服务对象
     */
    @Resource
    private GzhFunctionConfigService gzhFunctionConfigService;

    /**
     * 分页查询
     *
     * @param gzhFunctionConfig 筛选条件

     * @return 查询结果
     */
    @PostMapping("/query")
    @ApiOperation(value = "查询配置", httpMethod = "POST", notes = "查询配置")
    public String query(@RequestBody GzhFunctionConfig gzhFunctionConfig) {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
        if(gzhFunctionConfig.getEnterpriseId()!=null){
            gzhFunctionConfig.setStatus(1);
            gzhFunctionConfig.setDelFlag(0);
            gzhFunctionConfig.setGzhType(GzhFunctionConfig.GZHTYPE_MEMBERCENTER);
            List<GzhFunctionConfig> list=this.gzhFunctionConfigService.query(gzhFunctionConfig);
            ResultData<List<GzhFunctionConfig>> success = ResultData.success(list);
            return gson.toJson(success);
        }else{
            return gson.toJson(ResultData.error("请传enterpriseId"));
        }

    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
  /*  @GetMapping("{id}")
    public String queryById(@PathVariable("id") Long id) {
        return ResponseEntity.ok(this.gzhFunctionConfigService.queryById(id));
    }*/

    /**
     * 新增数据
     *
     * @param gzhFunctionConfig 实体
     * @return 新增结果
     */
   /* @PostMapping
    public String add(GzhFunctionConfig gzhFunctionConfig) {
        return ResponseEntity.ok(this.gzhFunctionConfigService.insert(gzhFunctionConfig));
    }*/

    /**
     * 编辑数据
     *
     * @param gzhFunctionConfig 实体
     * @return 编辑结果
     */
    /*@PutMapping
    public String edit(GzhFunctionConfig gzhFunctionConfig) {
        return ResponseEntity.ok(this.gzhFunctionConfigService.update(gzhFunctionConfig));
    }*/

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
   /* @DeleteMapping
    public String deleteById(Long id) {
        return ResponseEntity.ok(this.gzhFunctionConfigService.deleteById(id));
    }*/

}

